Common elements in a list(comparing two lists.)

29

list1 = [1,2,3,4,5,6]  
list2 = [7,8,9,2,10]  
for x in list1:  
    for y in list2:  
        if x == y:  
            print("The common element is:",x)

The common element is: 2

Comments

Submit
0 Comments